<template>
  <div class="view">
    <div>
      <img class="top" src="../assets/banner-top.png">
      <img class="top logo1" src="../assets/banner-logo1.png">
      <img class="top logo2" style="opacity: 0;" src="../assets/banner-logo2.png">
    </div>
    <div class="viewTop">
        <div class="colse" @click="goBack"><img src="../assets/close.png"></div>
        <h3>狮粉话语</h3>
        <span @click="$router.push('/view')" class="sendBtn edit">发布</span>
    </div>
    <div class="discourse-list">
        <p class="text">以幸福为主题，上传您的用车生活故事或精彩游记。我们精挑会 玩、能撩、肯写的东风标致408车主，送您成都车展体验之旅。</p>
        <form class="searchBox">
            <button>搜索 <i class="fa fa-search"></i></button>
            <input type="search" v-model="keywords">
        </form>
    </div>
    <div class="discourse" ref="lineBox">
        <div class="discourse_cont" >
            <span class="line" ></span>        
            <div class="head">
                <img class="userImg" src="../assets/user.png" alt="">
                <b class="name">风轻云淡</b>
            </div>
            <p class="content">和东风标致4008一起，遇见了多种自己，我想要的还有很多， XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。</p>
            <div class="imgBox">
                <img class="img" src="../assets/car.png" width="100%">
            </div>
            <div class="funBox">
                <span class="time">1小时前</span>
                <span class="like"><i class="fa fa fa-heart" aria-hidden="true"></i> 11</span>
                <span class="commenting"><i class="fa fa-commenting" aria-hidden="true"></i> 22</span>
            </div>
        </div>
        <div class="discourse_cont">
            <span class="line"></span>  
            <div class="head">
                <img class="userImg" src="../assets/user.png" alt="">
                <b class="name">宁静致远</b>
            </div>
            <p class="content">和东风标致4008一起，遇见了多种自己，我想要的还有很多， XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。</p>
            <div class="imgBox">
                <img class="img" src="../assets/car.png" width="100%">
            </div>
            <div class="funBox">
                <span class="time">1小时前</span>
                <span class="like"><i class="fa fa fa-heart" aria-hidden="true"></i> 11</span>
                <span class="commenting"><i class="fa fa-commenting" aria-hidden="true"></i> 22</span>
            </div>
        </div>
        <div class="discourse_cont">
            <span class="line"></span>  
            <div class="head">
                <img class="userImg" src="../assets/user.png" alt="">
                <b class="name">宁静致远</b>
            </div>
            <p class="content">和东风标致4008一起，遇见了多种自己，我想要的还有很多， XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX。</p>
            <div class="imgBox">
                <img class="img" src="../assets/car.png" width="100%">
            </div>
            <div class="funBox">
                <span class="time">1小时前</span>
                <span class="like"><i class="fa fa fa-heart" aria-hidden="true"></i> 11</span>
                <span class="commenting"><i class="fa fa-commenting" aria-hidden="true"></i> 22</span>
            </div>
        </div>
    </div>
  </div>
</template>
<script>
export default {
  data () {
      return {
        keywords:""
      }
  },
  created () {
      this.initHei()
  },
  methods: {
        goBack () {
            this.$router.back(-1);
        },
        initHei () {
            this.$nextTick(() => {
                let discourse_conts =  this.$refs.lineBox.getElementsByClassName("discourse_cont");
                Array.from(discourse_conts).forEach(element => {
                    var t = setInterval( () => {
                        if(element.getElementsByClassName("img")[0].complete){
                            let height = Number(element.offsetHeight) + 9;
                            element.getElementsByClassName("line")[0].style.cssText = 'height:'+height + 'px';
                            clearInterval(t)
                            return;
                        }
                    },50)
                });
            })
        }
  },
}
</script>
<style lang="scss" type="text/scss" scoped>
  body {
    background: #fff;
  }
    .view{
        .top {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            z-index: 2;
        }
        .viewTop{
            margin-top: 8vw;
            height: 8vh;
            width: 100%;
            background: url(../assets/viewTop.png) no-repeat center center;
            background-size: 100% auto;
            overflow: hidden;
            position: relative;
            color: #fff;
            .colse{
                float: left;
                width: 3.5vw;
                height: 3.5vw;
                margin: 2.4vh 0 0 4vw;
            }
            > h3 {
                position: absolute;
                top: 0;  
                left: 50%;
                width: 50vw;
                height: 8vh;
                line-height: 8vh;
                margin-left: -25vw;
                text-align:center;
            }
            .sendBtn{
                float: right;
                margin: 2.4vh 4vw 0 0;
                background: none;
                border: none;color: #fff;
                &.edit{
                    padding-right: 5vw;
                    background: url(../assets/edit.png) no-repeat right center;
                    background-size: 4vw auto;
                }
            }
        }
        .discourse-list{
            padding: 3vw;background: #efefef;
            .text{font-size: 12px;line-height: 1.5;color: #333;}
            .searchBox{
                margin-top: 2vh;
                padding:0 3vw;
                background: #fff;
                border-radius: 3px;
                height: 10vw;
                line-height: 10vw;
                > button {
                    font-size: 16px;
                    border: none;
                    color: #333;
                    background: none;
                }
                > input {
                    width: 65vw;
                    height: 6vw;
                    color: #444;
                    text-indent: 1vw;
                    border: none;
                    font-size: 14px;
                }
            }
        }
        .discourse{
            padding: 3vw;
            .discourse_cont{
                margin-bottom: 3vh;
                width: 88vw;float: right;
                position: relative;
                &::after{
                    content: "";
                    display: block;
                    position: absolute;
                    left: -6vw;
                    top: 4vw;
                    width: 3vw;height: 3vw;border: solid 1px #666;
                    border-radius: 50%;
                }
                &:not(:last-child) .line{
                    display: block;
                    position: absolute;
                    left: -4.6vw;
                    top: 7vw;
                    width: 1px;
                    background: #666;
                }
                .head{
                    overflow: hidden;
                    .userImg{
                        width: 12vw;height: 12vw;margin-right: 4vw;
                        float: left;
                    }
                    .name{
                        font-size: 14px;font-weight: bold;color: #333;
                        line-height: 12vw;
                        float: left;
                    }
                }
                .content{
                    font-size: 12px;color:#333;
                    margin: 1vw 0;
                    line-height: 1.5;
                }
                .funBox{
                    overflow: hidden;
                    .time{
                        padding: 1px 8px;
                        font-size: 12px;
                        margin-top: 5px;
                        background: #f0eded;
                        border-radius: 10px;
                        float: left;
                    }
                    .like{
                        float: right;
                        font-size: 12px;
                        margin-top: 5px;
                        .fa{font-size: 14px;}
                    }
                    .commenting{
                        float: right;
                        font-size: 12px;
                        margin-top: 5px;
                        margin-right: 3vw;
                        .fa{font-size: 14px;}
                    }
                }

            }
        }

    }
</style>
